<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>礼品</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../script/jquery.validation.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../script/district.js" ></script>
<script src="../script/my_lightbox.js" language="javascript"></script>
<script language="javascript">
var weburl="<{$config.weburl}>";
$(function(){
	$('#form').validate({
		errorPlacement:function(error, element){
			element.next('.form-error').append(error);
		},      
		rules :{
			name:{
				required:true
			},
			catid:{
				required:true
			},
			points:{
				required:true,
			},
			sku:{
				required:true,
			},
			stock:{
				required:true,
			}
		},
		messages :{
			name:{
				required:'请填写礼品名称',
			},
			catid:{
				required:'请填写分类',
			},
			price:{
				required:'请填写礼品价',
			},
			points:{
				required:'请填写所需积分',
			},
			sku:{
				required:'请填写礼品编号',
			},
			stock:{
				required:'请填写库存',
			}
		}
	});
});
</script>
</head>
<body>
	<div class="container">
        <div class="flow">
            <div class="itemtitle">
                <h3>礼品</h3>
                <ul>
                    <li <{if $smarty.get.operation==''}>class="current"<{/if}>><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>"><span>管理</span></a></li>
                    <li <{if $smarty.get.operation=='add'}>class="current"<{/if}>><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&operation=add"><span>添加</span></a></li>
                    <{if $smarty.get.operation=='edit'}>
                    <li class="current"><a href="#"><span>修改</span></a></li>
                    <{/if}>
                </ul>
            </div>
        </div>
        <div class="h35"></div>  
        <{if $smarty.get.operation=='add' or $smarty.get.operation=='edit' or $smarty.get.operation=='batch' }>
            <form name="form" id="form" method="post">
            <input name="id" type="hidden" id="id" value="<{$de.id}>">
            <table class="table table1">
                <thead>
                    <tr>
                        <th class="partition" colspan="99">礼品</th>
                    </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="100">礼品名称</td>
                    <td>
                    <input name="name" id="name" type="text" class="w350" value="<{$de.name}>">
                 	<div id="form-error" class="form-error"></div>
                    </td>
                </tr>
                
                <tr>
                    <td width="100">礼品编号</td>
                    <td>
                    <input name="sku" id="sku" type="text" class="w350" value="<{$de.sku}>">
                 	<div id="form-error" class="form-error"></div>
                    </td>
                </tr>
                
                <tr>
                    <td>礼品分类</td>
                    <td>
                    <select class="select" name='catid'>
                    	<option value=''>选择品牌分类</option>
                        <{foreach item=list from=$cat}>
                        <option <{if $de.catid==$list.id}> selected="selected" <{/if}>value="<{$list.id}>"><{$list.catname}></option>	
                        <{foreach item=slist from=$list.scat}>
                        <option <{if $de.catid==$slist.id}> selected="selected" <{/if}>value="<{$slist.id}>">┣ <{$slist.catname}></option>	
                        <{/foreach}> 
                        <{/foreach}> 
            		</select>
                    <div id="form-error" class="form-error"></div>
                    </td>
                </tr>
                
                <tr>
                    <td>市场价</td>
                    <td><input type="text" name="price" id="price" value="<{$de.price}>" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeyup="value=value.replace(/[^\d.]/g,'')" /><div id="form-error" class="form-error"></div></td>
				</tr>
                
                <tr>
                    <td>所需积分</td>
                    <td><input type="text" name="points" value="<{$de.points}>" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeyup="value=value.replace(/[^\d]/g,'')" /><div id="form-error" class="form-error"></div></td>
				</tr>
                
                <tr>
                    <td>礼品图片</td>
                    <td>
                    <input name="pic" class="w350" type="text" id="pic" value="<{$de.pic}>" />
                    <input name="oldpic" type="hidden" value="<{$de.pic}>" />
                    [<a href="javascript:uploadfile('上传LOGO','pic',500,300,'points')">上传</a>] 
                    [<a href="javascript:preview('pic');">预览</a>]
                    [<a onclick="javascript:$('#pic').val('');" href="#">删除</a>] <span class="bz"></span>
                    </td>
                </tr>
                
                <tr>
                    <td>库存</td>
                    <td><input type="text" name="stock" id="stock" value="<{if $de.stock}><{$de.stock}><{else}>1<{/if}>" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeyup="value=value.replace(/[^\d]/g,'')" /><div id="form-error" class="form-error"></div></td>
				</tr>
                
                <tr>
                    <td>点击数</td>
                    <td><input type="text" name="hits" value="<{if $de.hits}><{$de.hits}><{else}>0<{/if}>"  onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeyup="value=value.replace(/[^\d]/g,'')"/></td>
				</tr>
                
                <tr>
                    <td>礼品介绍</td>
                    <td>
                    <script charset="utf-8" src="../lib/kindeditor/kindeditor-min.js"></script>
					<script>
                    var editor;
                    KindEditor.ready(function(K) {
                        editor = K.create('textarea[name="content"]', {
                            resizeType :1,
                            allowPreviewEmoticons :false,
                            allowImageUpload :false
                        });
                    });
                    </script>
                    <textarea style="width:80%; height:300px" name="content"><{$de.content}></textarea>
                    </td>
				</tr>
                
                <tr>
                    <td>状态</td>
                    <td>
                    <input type="radio" name="status" value="2" id="tj" <{if $de.status==2}>checked="checked"<{/if}>/><label for="tj">推荐</label>
                    <input type="radio" name="status" value="1" id="open" <{if $de.status==1}>checked="checked"<{/if}>/><label for="open">开启</label>
                    <input type="radio" name="status" value="0" id="close" <{if $de.status==0}>checked="checked"<{/if}>/><label for="close">关闭</label>
                    </td>
                </tr>
               
                <tr>
                    <td>&nbsp;</td>
                    <td>
                    <input class="submit" type="submit" value="提交">
                    <input name="act" type="hidden" id="action" value="<{if !$smarty.get.editid}>save<{else}>edit<{/if}>">
                    </td>
                </tr>
                </tbody>
            </table>
            </form>
        <{else}>
		<script type="text/javascript">
        $(function(){
            /* 全选 */
             $('.checkall').click(function(){
                var _self = this;
                $('.checkitem').each(function(){
                    if (!this.disabled)
                    {
                        $(this).attr('checked', _self.checked);
                    }
                });
                $('.checkall').attr('checked', this.checked);
            });	 
        });
        </script>
        <form action="" method="post">
        <table class="table">
            <tbody>
                <tr class="header">
                    <th width="30"></th>
                    <th colspan="2" class="al">礼品名称</th>
                    <th width="100">所需积分</th>
                    <th width="100">市场价</th>
                    <th width="80">已兑换</th>
                    <th width="100">状态</th>
                    <th width="50"></th>
                </tr>
                <{foreach item=list from=$de.list}>
                <tr>
                    <td><input type="checkbox" value="<{$list.id}>" class="checkitem" name="chk[]"></td>
                    <td width="70"><a target="_blank" href="../?m=points&s=detail&id=<{$list.id}>"><{if $list.pic}><img width="60" class="img" src="<{$list.pic}>" /><{else}><img class="img" width="60" src="../image/default/nopic.gif" /><{/if}></a></td>
                    <td class="al">
                    <a target="_blank" href="../?m=points&s=detail&id=<{$list.id}>"><{$list.name}></a>
                    <p>分类：<{$list.catname}></p>
                    <p>编号：<{$list.sku}></p>
                    <p>库存：<{$list.stock}></p>
                    </td>
                    <td><{$list.points}></td>
                    <td><{$config.money}><{$list.price}></td>
                    <td>&nbsp;<{$list.sell_amount}></td>
                    <td><{if $list.status==1}>开启<{elseif $list.status==2}>推荐<{else}>关闭<{/if}></td>
                    <td>
                    <a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&operation=edit&editid=<{$list.id}>"><{$editimg}></a> 
                    <a onclick="return confirm('确定删除吗');" href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&delid=<{$list.id}>"><{$delimg}></a>
                    </td>
                </tr>
                <{foreachelse}>
                <tr>
                    <td class="norecord" colspan="99"><i></i><span>暂无符合条件的数据记录</span></td>
                </tr>
                <{/foreach}>
            </tbody>
            <tfoot>
                <tr>
                	<td colspan="4">
                        <input type="checkbox" class="checkall" id="del">
                        <input type="hidden" name="act" value="op" />
                        <input type="submit" name="submit" value="<{$lang.btn_submit}>" />
                        <input type="submit" name="submit" value="<{$lang.rc}>" />
                        <input type="submit" name="submit" value="<{$lang.btn_open}>" />
                        <input type="submit" name="submit" value="<{$lang.btn_close}>" />
                    </td>
                    <td colspan="99"><div class="page"><{$de.page}></div></td>
                </tr>
            </tfoot>
        </table>
        </form>
        <{/if}>
    </div>
</body>
</html>